{% extends base %}

{% block head %}

{% set-global search_action = '/fs_find' %}
{% set-global search_placeholder = '搜索文件' %}

{% end %}

{% block search_form %}
    <input type="text" name="path" class="hide" value="{{?path}}"/>
{% end %}

{% block body %}

{% init find_key = "" %}
{% init error = "" %}
{% init show_fs_path = True %}
{% init search_category = "fs" %}
{% init show_hidden_files = False %}

<div class="hide error row"></div>
<div class="hide success row"></div>

<div class="grid-card">
    {% include fs/component/fs_title.html %}
</div>

<div class="card">

{% if show_fs_path %}
    {% include mod_fs_path.html %}
{% end %}

{% include fs/component/options/fs_options.html %}

<div class="col-md-12 file-list fs-scrollbar">
<table class="col-md-12 no-border-table">
{% for item in filelist %}
    {# 隐藏文件 #}
    {% if item.name == "" %}
        {% set print("overflow fileItem=%s" % item) %}
        {% continue %}
    {% end %}

    {% if not show_hidden_files and (item.name[0] == "." or item.name.endswith((".pyc", ".class"))) %}
        {% continue %}
    {% end %}

    <tr>
        <td class="checkboxTd"><input type="checkbox" data-path="{{item.path}}" data-name="{{item.name}}"></td>
        <td>
            <i class="fa {{item.icon}}"></i>

            {% if item.type == "dir" %}
                <a href="/fs/{{item.encoded_path}}?mode={{mode}}" class="fs-folder">{{item.name}}</a>
            {% elif xutils.is_img_file(item.path) %}
                <a href="#" class="x-photo" src="/fs/{{item.encoded_path}}">{{item.name}}</a>
            {% elif xutils.is_audio_file(item.path) %}
                <a href="#" class="x-audio" data-src="/fs/{{item.encoded_path}}">{{item.name}}</a>
            {% else %}
                <a href="/fs_view?path={{url_escape(item.path)}}">{{item.name}}</a>
            {% end %}
        </td>

        <td class="options-td">
            {{item.size}}
        </td>
        <td class="options-td">
            <div class="float-right">
                {% if item.type != "dir" %}
                    {# 编辑器，主要有两张：文本编辑器和二进制编辑器 #}
                    <a class="item-option" href="/fs_edit?path={{url_escape(item.path)}}">编辑</a>
                    <a class="item-option" href="/fs/{{item.encoded_path}}?type=blob&token={{token}}">下载</a>
                {% else %}
                    <a class="item-option" 
                        data-path="{{item.path}}"
                        onclick="openFileOption(this)">更多</a>
                {% end %}
            </div>
        </td>
        
    </tr>
        
{% end %}
</table>

<input type="text" class="cmd-input" placeholder="请输入指令">
</div>
</div>

{% if error != "" %}
<div class="card">
    <pre class="error col-md-12">{{error}}</pre>
</div>
{% end %}

{% end %}

{% block aside %}
    {% include fs/mod_aside.html %}
{% end %}